import request from '@/utils/request'
import { encryption } from '@/utils/util'

export const getCacUserAPI = (data: any) => {
    return request.get({
        url: '/admin/m/cacUser/page',
        data
    })
}

//购买客户
export const buyCustomerAPI = (data: any) => {
    return request.post({
        url: '/admin/m/cacUser/buy-customer',
        data
    })
}

/**
 * 用户邮件配置-添加|更新
 */
export const saveUserEmailConfigAPI = (data: any) => {
    const password = encryption(data.password, import.meta.env.VITE_PWD_ENC_KEY)

    return request.post({
        url: '/admin/m/cacUser/userMailConfig',
        data: {
            ...data,
            password: password,
            auth: true,
            starttls: true
        }
    })
}

/**
 * 获取用户邮件配置
 */
export const getUserEmailConfigAPI = (data: any) => {
    return request.get({
        url: '/admin/m/cacUser/userMailConfig',
        data: {}
    })
}

/**
 * 群发邮件
 */
export const sendEmailAPI = (data: any) => {
    return request.post({
        url: '/admin/m/cacUser/userMailConfig/send',
        data
    })
}
